/*
 * TextCustomizer.java
 *
 * Created on January 26, 2009, 2:30 PM
 */

package org.netbeans.modules.web.stripes.palette.items;

import org.netbeans.modules.web.stripes.palette.CodeSnippet;
import org.netbeans.modules.web.stripes.palette.CodeSnippetCustomizer;

/**
 *
 * @author  Josef Sustacek
 */
public class TextCustomizer extends CodeSnippetCustomizer {

    /** Creates new form TextCustomizer */
    public TextCustomizer(CodeSnippet codeSnippet) {
        super(codeSnippet);
        
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        nameText = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        disabledBox = new javax.swing.JCheckBox();
        readonlyBox = new javax.swing.JCheckBox();

        jLabel1.setText(org.openide.util.NbBundle.getMessage(TextCustomizer.class, "TextCustomizer.jLabel1.text")); // NOI18N

        nameText.setText(org.openide.util.NbBundle.getMessage(TextCustomizer.class, "TextCustomizer.nameText.text")); // NOI18N

        jLabel2.setText(org.openide.util.NbBundle.getMessage(TextCustomizer.class, "TextCustomizer.jLabel2.text")); // NOI18N

        disabledBox.setText(org.openide.util.NbBundle.getMessage(TextCustomizer.class, "TextCustomizer.disabledBox.text")); // NOI18N

        readonlyBox.setText(org.openide.util.NbBundle.getMessage(TextCustomizer.class, "TextCustomizer.readonlyBox.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nameText, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(disabledBox)
                    .addComponent(readonlyBox))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addGap(30, 30, 30))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(disabledBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(readonlyBox)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox disabledBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField nameText;
    private javax.swing.JCheckBox readonlyBox;
    // End of variables declaration//GEN-END:variables

    @Override
    protected void evaluateInput() {
        codeSnippet.setProperty(Text.NAME, nameText.getText());
        codeSnippet.setProperty(Text.DISABLED, disabledBox.isSelected() ? "disabled" : "");
        codeSnippet.setProperty(Text.READONLY, readonlyBox.isSelected() ? "readonly" : "");
    }
}
